import { fetchOrderDetail } from '../../../services/order/orderDetail';
import { api } from '../../../config/api';
import { request } from '../../../utils/request';

Page({
	data: {
		invoice: {},
	},
	onLoad({ orderId }) {
		this.orderId = orderId;
		this.init();
	},
	init() {
		this.getDetail();
	},
	getDetail() {
		request.get(api.order.invoice, { orderId: this.orderId })
			.then(res => {
				const invoice = {
					buyerName: res.buyerName, //个人或公司名称
					buyerTaxNo: res.buyerTaxNo, //税号
					buyerPhone: res.buyerPhone, //手机
					email: res.email, //邮箱
					titleType: res.titleType === 1 ? '个人' : '公司', //发票抬头 1-个人 2-公司
					ontentType: res.ontentType === 1 ? '商品明细' : '类别', //发票内容 1-明细 2类别
					invoiceType: res.invoiceType === 5 ? '电子普通发票' : '不开发票', //是否开票 0-不开 5-电子发票
					isInvoice: res.buyerName ? '已开票' : '未开票',
					money: res.money,
				};
				this.setData({
					invoice,
				});
			});
	},
});
